import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.event.*;

public class PerLogicArtGUI extends JFrame implements ActionListener {
  
	private static final long serialVersionUID = 1L;

	JMenuBar menuBar; 
	JMenu fileMenu;
	JMenu newMenu; 
	JMenuItem newDrawingItem, newTrainingItem, saveItem, openItem; 
        
    //================================================ Constructor
    public PerLogicArtGUI() {
	Init();
    }
	
    //========================================================== main

	private void Init() {
		InitMenu();
		InitContent();		
		InitWindow();
	}
	
	private void InitMenu() {
		//create the menus and add content
		 menuBar = new JMenuBar(); 
		 
		 fileMenu = new JMenu("File"); 
		 menuBar.add(fileMenu); 
		
		 newMenu = new JMenu("New");		 
		 newDrawingItem = new JMenuItem("New Drawing"); 
		 newDrawingItem.addActionListener(this); 
		 newTrainingItem = new JMenuItem("New Training"); 
		 newTrainingItem.addActionListener(this); 
		 newMenu.add(newDrawingItem); 
		 newMenu.add(newTrainingItem); 
		 fileMenu.add(newMenu); 
		 
		 saveItem = new JMenuItem("Save"); 
		 saveItem.addActionListener(this); 
		 openItem = new JMenuItem ("Open"); 
		 openItem.addActionListener(this); 
		 fileMenu.add(saveItem); 
		 fileMenu.add(openItem); 
		
		
		 setJMenuBar(menuBar); 
	}

	private void InitContent() {
	    	//content is the panel that will hold both the shapesWindow, settingsWindow, and Canvas	    		    		    	
	    	JPanel content = new JPanel();
	        content.setLayout(new BorderLayout(5, 5));
	        content.add(SettingsWindow.Obj(), BorderLayout.SOUTH); 
	        content.add(ShapesWindow.Obj(), BorderLayout.WEST);
	        //content.add(canvas, BorderLayout.CENTER); 
	        content.add(Canvas.Obj(), BorderLayout.CENTER);

	        //... Set window characteristics
	        setContentPane(content);
	}

	void InitWindow() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setTitle("PerLogicArt");
		pack();
	}
		
     	public void actionPerformed(ActionEvent e) {
		JMenuItem source = (JMenuItem)(e.getSource()); 
		if (source == newDrawingItem){
			PLDebug.Info("Making a new drawing");
			PLGuiInfo.Obj().SetCurCanvasId(Canvas.CanvasIdT.kDrawing);
		}
		
		if (source == newTrainingItem){
			PLDebug.Info("Making a new training");
			PLGuiInfo.Obj().SetCurCanvasId(Canvas.CanvasIdT.kTraning);
		}
		if (source == saveItem){
			PLDebug.Info("Saving item");
			//create Record from the getRecord() of canvas class. Then clear that record to wait for the next trainting session. 
		}
		if (source == openItem){
			PLDebug.Info("open item");
			//have to work out how to implement directories and doing that kind of business, not that important for now. 
		}
	}

	public static void main(String[] args) {
		JFrame window = new PerLogicArtGUI();
		window.setVisible(true);
	}


}
